
#include<iostream>
#include<cstring>
#include"comm.hpp"
#include"time.hpp"
#include"fifo.hpp"



//模拟客户端接收数据
int main()
{
    
    std::cout << "time:" << Gettime() << std::endl;

    shm.cjshm();//创建共享内存

    shm.attshm();//挂接到虚拟地址空间

    gpipe.openread();

    //sleep(10);
    //获取起始虚拟地址
    struct data* img = (struct data*)shm.getaddr();
    

    //在这里进行通信
    while(true)
    {
        gpipe.Wait();
        printf("status:%s\n",img->status);
        printf("lasttime:%s\n",img->lasttime);
        printf("imge:%s\n",img->imge);

        strcpy(img->status,"过期");
        sleep(3);
    }


    shm.dateshm();
    std::cout << "去关联" << std::endl;

    sleep(10);
    shm.deleshm(); 
    std::cout << "删除共享内存" << std::endl;
    return 0;
}







// int main()
// {
    

//     sleep(5);


//     sleep(5);

//     //在这里通信

//     //去关联


//     sleep(5);
//     //删除共享内存
//     shmctl(shmid,IPC_RMID,nullptr);
//     std::cout << "删除共享内存" << std::endl;
    
//     return 0;
// } 